package com.ruoyi.web.controller.mini;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.MiniLoginUser;
import com.ruoyi.framework.security.context.UserContextHolder;
import com.ruoyi.system.domain.MyTheme;
import com.ruoyi.system.service.IMyHistoryService;
import com.ruoyi.system.service.IMyThemeService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mini/chat")
@Api(tags = "聊天相关接口")
public class ChatController extends BaseController {

    @Autowired
    private IMyThemeService myThemeService;
    @Autowired
    private IMyHistoryService myHistoryService;

    /**
     * 查询聊天列表
     */
    @GetMapping("/list")
    public AjaxResult list(String keyword) {
        MiniLoginUser currentUser = UserContextHolder.getCurrentUser();
        return success(myHistoryService.selectMyHistoryList(keyword, currentUser));
    }

    /**
     * 获取聊天主题列表
     */
    @GetMapping("/themeList")
    public AjaxResult themeList() {
        LambdaQueryWrapper<MyTheme> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MyTheme::getStatus, 1);
        return success(myThemeService.list(queryWrapper));
    }

}
